home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / Run & Stumpy / source / directoryloop.cp < prev    next >
Encoding:
Text File  |  1992-06-18  |  863 b   |  42 lines  |  [TEXT/MPS ]

  1. #define SystemSevenOrLater 1
  2.  
  3. #include "directoryloop.h"
  4.  
  5. directoryloop::directoryloop( const FSSpec& directory )
  6.   {
  7.     pb.hFileInfo.ioCompletion= 0;
  8.     
  9.     pb.hFileInfo.ioNamePtr= (StringPtr)&directory.name;
  10.     pb.hFileInfo.ioVRefNum= directory.vRefNum;
  11.     pb.hFileInfo.ioDirID= directory.parID;
  12.     pb.hFileInfo.ioFDirIndex= 0;
  13.  
  14.     error= PBGetCatInfoSync( &pb );
  15.     if (iswrong())
  16.         return;
  17.     
  18.     dirid= pb.hFileInfo.ioDirID;
  19.     
  20.     pb.hFileInfo.ioNamePtr= (StringPtr)&thename;
  21.     pb.hFileInfo.ioFDirIndex= 1;
  22.     error= PBGetCatInfoSync( &pb );
  23.   }
  24.  
  25. void directoryloop::next()
  26.   {
  27.     pb.hFileInfo.ioDirID= dirid;
  28.     pb.hFileInfo.ioFDirIndex++;
  29.     error= PBGetCatInfoSync( &pb );
  30.   }
  31.  
  32. OSErr directoryloop::makespec( FSSpec& spec )
  33.   {
  34.     if (iswrong())
  35.         return whatiswrong();
  36.  
  37.     return FSMakeFSSpec( pb.hFileInfo.ioVRefNum,
  38.                                 dirid,
  39.                                 (ConstStr255Param)&thename,
  40.                                 &spec );
  41.   }
  42.